﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
using ZCMS.Configuration;
using ZCMS.Web;

namespace ZCMS.EntityFrameworkCore
{
public	class RWDBDbContextFactory: IDesignTimeDbContextFactory<RWDBDbContext>
	{
		public RWDBDbContext CreateDbContext(string[] args)
		{
			var builder = new DbContextOptionsBuilder<RWDBDbContext>();
			var configuration = AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder());

			RWDBDbContextOptionsConfigurer.Configure(
				builder,
				configuration.GetConnectionString(ZCMSConsts.ConnectionStringName_RWDB)
			);

			return new RWDBDbContext(builder.Options);
		}
	}
}
